package com.xumt.hwHMSdemo.Adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.xumt.hwHMSdemo.R;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class ShoppingcarAdapter extends RecyclerView.Adapter<ShoppingcarAdapter.ViewHolder> {
    private List<String> shopname;
    private Context context;
    private List<String>disrciptionlist;
    private List<String>commdity_pricelist;
    private List<List<Map<String,Object>>> Shopcargoring=new ArrayList<>();
    public ShoppingcarAdapter(Context context,List<List<Map<String,Object>>> Shopcargoring,List<String>shopname)
    {
        this.context=context;
        this.shopname=shopname;
        this.Shopcargoring=Shopcargoring;
    }
    static class ViewHolder extends RecyclerView.ViewHolder{
        private TextView name;
        private RecyclerView recyclerView;
        private ImageView imageView;
        private TextView allprice;
        public ViewHolder(View view)
        {
            super(view);
            name=(TextView)view.findViewById(R.id.formshop);
            imageView=(ImageView)view.findViewById(R.id.shopcoin);
            recyclerView=(RecyclerView)view.findViewById(R.id.commodityview);
            allprice=(TextView)view.findViewById(R.id.allprice);
            RecyclerView.LayoutManager manager=new LinearLayoutManager(view.getContext());
            manager.setAutoMeasureEnabled(true);
            recyclerView.setLayoutManager(manager);
        }
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view= LayoutInflater.from(parent.getContext()).inflate(R.layout.activity_newshoppingcar2,parent,false);
        return new ViewHolder(view);

    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        holder.name.setText(shopname.get(position));
        holder.imageView.setImageResource(R.drawable.shopcoin2);
//       if(holder.recyclerView.getAdapter()==null) {
            holder.recyclerView.setAdapter(new CommodityAdapter(context,Shopcargoring.get(position)));
//        }



    }

    @Override
    public int getItemCount() {
        return shopname.size();
    }




}
